@echo off
set tag=%1
set environment=%2

if "%environment%"=="" SET environment="test"

if "%tag%"=="" (
  echo tag is null
  echo %environment%
) else (
  docker images |grep huangding/car_loan |grep -v ${tagName} |awk '{print $3}'|xargs docker rmi -f
  mvn package -P%environment% -Dmaven.test.skip
  docker build -t huangding/car_loan:%tag% .
  for /f "usebackq" %%s in (`^docker images huangding/car_loan:%tag% ^|awk '{print $3}' ^|awk END'{print $1}' `) do (
    docker tag %%s registry.cn-hangzhou.aliyuncs.com/huangding/car_loan:%tag%
  )
   docker push registry.cn-hangzhou.aliyuncs.com/huangding/car_loan:%tag%
   docker rmi -f huangding/car_loan:%tag%
)



